if (OBJECT_ID('sp_getConversationContacts') is not null)
	drop procedure sp_getConversationContacts;
go

create procedure sp_getConversationContacts
@userID varchar(100)
as

select distinct FromID as UserID, UserName from [Message]
join aspnet_Users on FromID = aspnet_Users.UserId
where FromID <> @userID
and ToID = @userID

union

select distinct ToID as UserID, UserName from [Message]
join aspnet_Users on ToID = aspnet_Users.UserId
where ToID <> @userID
and FromID = @userID
